libkovan  1
The kovan standard library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
thread.hpp
Go to the documentation of this file.
1 #ifndef _THREAD_HPP_
2 #define _THREAD_HPP_
3 
4 #ifndef WIN32
5 #include <pthread.h>
6 #else
7 #define WIN32_LEAN_AND_MEAN
8 #include <windows.h>
9 #endif
10 
11 #include "export.h"
12 
14 {
15 public:
16  Mutex();
17  ~Mutex();
18 
19  void lock();
20  bool tryLock();
21 
22  void unlock();
23 
24 private:
25  Mutex(const Mutex &rhs);
26 
27 #ifdef WIN32
28  CRITICAL_SECTION m_handle;
29 #else
30  pthread_mutex_t m_handle;
31 #endif
32 };
33 
35 {
36 public:
37  Thread();
38  virtual ~Thread();
39 
40  void start();
41  void join();
42 
43  virtual void run() = 0;
44 
45 private:
46 #ifndef WIN32
47  pthread_t m_thread;
48 #else
49  HANDLE m_thread;
50 #endif
51 };
52 
53 #endif